const app = getApp()
Page({
  data: {
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
  },
  
  bindGetUserInfo: function (e) {
    if (e.detail.userInfo) {
      //用户键入授权按钮
      openConfirm: {
        wx.showModal({
          title: '授权登录',
          content: '我们只需要您的昵称和地理位置，并进行保密',
          confirmText: "同意",
          cancelText: "拒绝",
          success: function (res) {
            console.log(res);
            
            if (res.confirm) {
              console.log('用户同意')
              app.globalData.hasUserInfo = true;
              wx.getUserInfo({
                success: e => {
                  console.log(e)
                  app.globalData.userInfo = e.userInfo
                }
              })
              tiaozhuan:{
                console.log('用户已经前往主页')
                wx.navigateTo({
                  url: '../index/index'
                })
              }


            } else {
              console.log('用户拒绝')
              openAlert: {
                wx.showModal({
                  content: '很遗憾您拒绝了，您无法享用本程序带来的乐趣',
                  showCancel: false,
                  success: function (res) {
                    if (res.confirm) {
                      console.log('用户已知晓后果')
                    }
                  }
                });
              }
            }
          }
        });
      }
    } 
}
});